# -*- encoding=utf8 -*-
__author__ = "kaizhang"

import re

from airtest.core.api import *

auto_setup(__file__)
from poco.drivers.ios import iosPoco


connect_device("iOS:///127.0.0.1:8300")
poco = iosPoco()

v = poco('Final price').sibling("price_label").attr('value')

final_price = re.findall('\d+\.\d+', v)[0]
print(final_price)




# d = {'id': None, 'payTaskId': 6419774, 'status': None, 'errorType': 1, 'errorMessage': None,
#                    'accountUsername': '3f23aedc8ecb4a39@hotmail.com', 'accountPassword': 'Aa1)lgLRd4',
#                    'linkEmailPassword': 'Aa1)lgLRd4', 'nameList': ['SMITH/RICHARD'], 'accountType': 'MEMBER', 'pnr': '',
#                    'bigPnr': None, 'sourceCur': 'GBP', 'targetCur': 'GBP', 'ticketAmount': 0.0, 'baggagePrice': None,
#                    'baggageCur': None, 'webPrice': None, 'linkEmail': '3f23aedc8ecb4a39@hotmail.com',
#                    'linkPhone': '15118115749', 'verifyPnrPrice': None, 'verifyPnrCur': None,
#                    'verifyPnrBaggagePrice': None, 'promo': None, 'machineCode': None, 'clientType': None,
#                    'checkStatus': True, 'needPnrVerifyStatus': True, 'createTaskStatus': True,
#                    'needRetToPlatform': True, 'itineraryPnrList': None, 'paymentVoList': [
#                  {'id': 6538227, 'orderPnrId': None, 'payChannel': 1, 'payType': 1, 'orderNo': '970787620',
#                   'orderPayTaskId': 6419774, 'cardName': 'ApplePay', 'cardNumber': 'ApplePay', 'settlementAmount': None,
#                   'settlementCurrency': None, 'remark': None, 'del': 0, 'createTime': None}], 'badMemberAccount': False,
#                    'pointLeft': None, 'accountSlotLeft': None, 'sellkey': None, 'submitSellkey': None,
#                    'orderSource': None, 'tradeOrderId': None, 'expiryTime': None, 'holdTimes': None,
#                    'holdTimesLimit': None, 'autoBrushTask': False, 'memberStatus': None, 'availableSeatCount': None,
#                    'payUrl': None, 'nextStepClient': None, 'passengerList': None, 'channelOrderNo': None, 'cabin': None,
#                    'depPayAmount': None, 'retPayAmount': None, 'depBagAmount': None, 'retBagAmount': None}

# # try:
# poco('Booking Confirmation',type='NavigationBar').wait_for_appearance()
# # except PocoTargetTimeout :
# #     d['status'] = '403'
# d['status'] = 405
# t:str = poco('booking_reference').attr('value')
# order_num = ''.join(re.split(f"\s+",t))
# d['pnr'] = order_num

# swipe((0.5,0.5),(0.5,0.1))
# # poco('Fare breakdown').click()
# price = poco('Fare total').sibling('price_label').attr('value')

# fare_total_price = re.findall('\d+\.\d+',price)[0]

# d['ticketAmount'] = float(fare_total_price)

# if not poco('Extras total').sibling('price_label').exists():
#     swipe((0.5, 0.5), (0.5, 0.2))

# luggage = poco('Extras total').sibling('price_label').attr('value')
# luggage_price = re.findall('\d+\.\d+',luggage)[0]

# d['baggagePrice'] = float(luggage_price)
# print(d)

# # luggage = poco('Extras').sibling('price_break_down').offspring('price_label').get_text()











